package psi

import (
	"fmt"
	"strings"
)

/*
数据上传间隔设置
平台发送:
10
[DW*YYYYYYYYYYYYYYY*LEN*UPLOAD,时间间隔]
实例:[DW*334588000000156*0009*UPLOAD,600]
终端回复:
[DW*YYYYYYYYYYYYYYY*LEN*UPLOAD]
实例:[DW*334588000000156*0006*UPLOAD]
说明:设置终端定时上报位置的时间间隔，单位是秒，此上传间隔针对手表处于运动状态时，手表静
止时不传位置数据。（出厂时默认上传间隔为十分钟)
*/

// 数据上传间隔设置
type UPLOAD struct {
	Interval int // 时间间隔
}

func DealUPLOAD(method string, params map[string]interface{}) (string, error) {
	var upload UPLOAD
	err := MapToStruct(params, &upload)
	if err != nil {
		return "", err
	}
	var messageList []string
	messageList = append(messageList, "UPLOAD")
	messageList = append(messageList, fmt.Sprint(upload.Interval))
	message := strings.Join(messageList, ",")
	return message, nil
}
